<!DOCTYPE HTML>
<html lang="en" >
    <!-- Start book 美多商城 -->
    <head>
        <!-- head:start -->
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <title>Django部署 | 美多商城</title>
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <meta name="description" content="">
        <meta name="generator" content="GitBook 2.6.7">
        
        
        <meta name="HandheldFriendly" content="true"/>
        <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <link rel="apple-touch-icon-precomposed" sizes="152x152" href="gitbook/images/apple-touch-icon-precomposed-152.png">
        <link rel="shortcut icon" href="gitbook/images/favicon.ico" type="image/x-icon">
        
    <link rel="stylesheet" href="gitbook/style.css">
    
        
        <link rel="stylesheet" href="gitbook/plugins/gitbook-plugin-toggle-chapters/toggle.css">
        
    
        
        <link rel="stylesheet" href="gitbook/plugins/gitbook-plugin-highlight/website.css">
        
    
        
        <link rel="stylesheet" href="gitbook/plugins/gitbook-plugin-search/search.css">
        
    
        
        <link rel="stylesheet" href="gitbook/plugins/gitbook-plugin-fontsettings/website.css">
        
    
    

        
    
    
    
    <link rel="prev" href="./C09-Database/ReadWriteSeparate.html" />
    

        <!-- head:end -->
    </head>
    <body>
        <!-- body:start -->
        
    <div class="book"
        data-level="10"
        data-chapter-title="Django部署"
        data-filepath="C10-Deploy.md"
        data-basepath="."
        data-revision="Sat Sep 01 2018 17:18:16 GMT+0800 (CST)"
        data-innerlanguage="">
    

<div class="book-summary">
    <nav role="navigation">
        <ul class="summary">
            
            
            
            

            

            
    
        <li class="chapter " data-level="0" data-path="index.html">
            
                
                    <a href="./index.html">
                
                        <i class="fa fa-check"></i>
                        
                        美多商城
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1" data-path="C01-Prepare/index.html">
            
                
                    <a href="./C01-Prepare/index.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.</b>
                        
                        项目准备
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.1" data-path="C01-Prepare/BusinessModel.html">
            
                
                    <a href="./C01-Prepare/BusinessModel.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.1.</b>
                        
                        商业模式
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="C01-Prepare/DevelopmentProcess.html">
            
                
                    <a href="./C01-Prepare/DevelopmentProcess.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.2.</b>
                        
                        开发流程
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="C01-Prepare/ProductAnalysis.html">
            
                
                    <a href="./C01-Prepare/ProductAnalysis.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.3.</b>
                        
                        需求分析
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="C01-Prepare/ProjectStructure.html">
            
                
                    <a href="./C01-Prepare/ProjectStructure.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.4.</b>
                        
                        项目架构
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="C01-Prepare/StartProject.html">
            
                
                    <a href="./C01-Prepare/StartProject.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.5.</b>
                        
                        创建工程
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="C01-Prepare/Config.html">
            
                
                    <a href="./C01-Prepare/Config.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.6.</b>
                        
                        配置
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2" data-path="C02-Users/index.html">
            
                
                    <a href="./C02-Users/index.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.</b>
                        
                        用户部分
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.1" data-path="C02-Users/UserModel.html">
            
                
                    <a href="./C02-Users/UserModel.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.1.</b>
                        
                        用户模型类
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.2" data-path="C02-Users/Domain.html">
            
                
                    <a href="./C02-Users/Domain.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.2.</b>
                        
                        设置域名
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.3" data-path="C02-Users/CORS.html">
            
                
                    <a href="./C02-Users/CORS.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.3.</b>
                        
                        跨域CORS
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.4" data-path="C02-Users/RegisterAnalysis.html">
            
                
                    <a href="./C02-Users/RegisterAnalysis.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.4.</b>
                        
                        注册
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.4.1" data-path="C02-Users/SMSCode.html">
            
                
                    <a href="./C02-Users/SMSCode.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.4.1.</b>
                        
                        短信验证码
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.4.2" data-path="C02-Users/CelerySendSMSCode.html">
            
                
                    <a href="./C02-Users/CelerySendSMSCode.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.4.2.</b>
                        
                        使用Celery发送短信
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.4.3" data-path="C02-Users/AccountExistingCheck.html">
            
                
                    <a href="./C02-Users/AccountExistingCheck.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.4.3.</b>
                        
                        判断帐号是否存在
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.4.4" data-path="C02-Users/Register.html">
            
                
                    <a href="./C02-Users/Register.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.4.4.</b>
                        
                        注册
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2.5" data-path="C02-Users/JWT.html">
            
                
                    <a href="./C02-Users/JWT.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.5.</b>
                        
                        JWT
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.5.1" data-path="C02-Users/DRF-JWT.html">
            
                
                    <a href="./C02-Users/DRF-JWT.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.5.1.</b>
                        
                        drf JWT
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2.6" data-path="C02-Users/Login.html">
            
                
                    <a href="./C02-Users/Login.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.6.</b>
                        
                        登录
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.7" data-path="C02-Users/QQLogin/index.html">
            
                
                    <a href="./C02-Users/QQLogin/index.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.7.</b>
                        
                        QQ登录
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.7.1" data-path="C02-Users/QQLogin/Step1.html">
            
                
                    <a href="./C02-Users/QQLogin/Step1.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.7.1.</b>
                        
                        第一步:获取url
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.7.2" data-path="C02-Users/QQLogin/Step2.html">
            
                
                    <a href="./C02-Users/QQLogin/Step2.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.7.2.</b>
                        
                        第二步:获取openID
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.7.3" data-path="C02-Users/QQLogin/Step3.html">
            
                
                    <a href="./C02-Users/QQLogin/Step3.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.7.3.</b>
                        
                        第三步:绑定账户
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.7.4" data-path="C02-Users/QQLogin/Step4.html">
            
                
                    <a href="./C02-Users/QQLogin/Step4.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.7.4.</b>
                        
                        itsdangerous
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2.8" data-path="C02-Users/UserInfo.html">
            
                
                    <a href="./C02-Users/UserInfo.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.8.</b>
                        
                        用户中心个人信息
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.9" data-path="C02-Users/Email/index.html">
            
                
                    <a href="./C02-Users/Email/index.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.9.</b>
                        
                        邮件与验证
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.9.1" data-path="C02-Users/Email/DjangoEmail.html">
            
                
                    <a href="./C02-Users/Email/DjangoEmail.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.9.1.</b>
                        
                        Django发送邮件的方法
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.9.2" data-path="C02-Users/Email/SendEmail.html">
            
                
                    <a href="./C02-Users/Email/SendEmail.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.9.2.</b>
                        
                        保存邮箱并发送验证邮件
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.9.3" data-path="C02-Users/Email/VerifyEmail.html">
            
                
                    <a href="./C02-Users/Email/VerifyEmail.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.9.3.</b>
                        
                        验证邮箱链接
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2.10" data-path="C02-Users/Address/index.html">
            
                
                    <a href="./C02-Users/Address/index.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.10.</b>
                        
                        收货地址
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.10.1" data-path="C02-Users/Address/AreaSelect.html">
            
                
                    <a href="./C02-Users/Address/AreaSelect.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.10.1.</b>
                        
                        省市区地址查询
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.10.2" data-path="C02-Users/Address/Cache.html">
            
                
                    <a href="./C02-Users/Address/Cache.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.10.2.</b>
                        
                        使用缓存
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.10.3" data-path="C02-Users/Address/UserAddressManagement.html">
            
                
                    <a href="./C02-Users/Address/UserAddressManagement.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.10.3.</b>
                        
                        用户地址管理
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.10.4" data-path="C02-Users/Address/UserAddressCode.html">
            
                
                    <a href="./C02-Users/Address/UserAddressCode.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.10.4.</b>
                        
                        用户地址代码
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="3" data-path="C03-Goods/index.html">
            
                
                    <a href="./C03-Goods/index.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.</b>
                        
                        商品部分
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.1" data-path="C03-Goods/DatabaseDesign.html">
            
                
                    <a href="./C03-Goods/DatabaseDesign.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.1.</b>
                        
                        数据表设计
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.1.1" data-path="C03-Goods/DatabaseGoods.html">
            
                
                    <a href="./C03-Goods/DatabaseGoods.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.1.1.</b>
                        
                        商品模型类
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.1.2" data-path="C03-Goods/DatabaseContents.html">
            
                
                    <a href="./C03-Goods/DatabaseContents.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.1.2.</b>
                        
                        广告模型类
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.1.3" data-path="C03-Goods/DatabaseMigrate.html">
            
                
                    <a href="./C03-Goods/DatabaseMigrate.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.1.3.</b>
                        
                        迁移
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="3.2" data-path="C03-Goods/FastDFS.html">
            
                
                    <a href="./C03-Goods/FastDFS.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.2.</b>
                        
                        FastDFS分布式文件系统
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.3" data-path="C03-Goods/Docker/index.html">
            
                
                    <a href="./C03-Goods/Docker/index.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.3.</b>
                        
                        Docker使用
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.3.1" data-path="C03-Goods/Docker/Introduce.html">
            
                
                    <a href="./C03-Goods/Docker/Introduce.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.3.1.</b>
                        
                        Docker简介
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.3.2" data-path="C03-Goods/Docker/InstallAndOperations.html">
            
                
                    <a href="./C03-Goods/Docker/InstallAndOperations.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.3.2.</b>
                        
                        安装与操作
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="3.4" data-path="C03-Goods/FastDFSDocker.html">
            
                
                    <a href="./C03-Goods/FastDFSDocker.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.4.</b>
                        
                        使用Docker安装FastDFS
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.5" data-path="C03-Goods/FastDFSClientAndDjangoFileSystem.html">
            
                
                    <a href="./C03-Goods/FastDFSClientAndDjangoFileSystem.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.5.</b>
                        
                        FastDFS客户端与自定义文件存储系统
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.6" data-path="C03-Goods/CKEditor.html">
            
                
                    <a href="./C03-Goods/CKEditor.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.6.</b>
                        
                        CKEditor富文本编辑器
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.7" data-path="C03-Goods/ImportGoodsData.html">
            
                
                    <a href="./C03-Goods/ImportGoodsData.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.7.</b>
                        
                        添加测试数据
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.8" data-path="C03-Goods/FreezeHTML.html">
            
                
                    <a href="./C03-Goods/FreezeHTML.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.8.</b>
                        
                        页面静态化
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.9" data-path="C03-Goods/DjangoCrontab.html">
            
                
                    <a href="./C03-Goods/DjangoCrontab.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.9.</b>
                        
                        定时任务
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.10" data-path="C03-Goods/CategoryQuery.html">
            
                
                    <a href="./C03-Goods/CategoryQuery.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.10.</b>
                        
                        查询分类的封装
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.11" data-path="C03-Goods/GoodsList.html">
            
                
                    <a href="./C03-Goods/GoodsList.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.11.</b>
                        
                        商品列表页
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.12" data-path="C03-Goods/GoodsSearch.html">
            
                
                    <a href="./C03-Goods/GoodsSearch.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.12.</b>
                        
                        商品搜索
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.13" data-path="C03-Goods/GoodsDetail.html">
            
                
                    <a href="./C03-Goods/GoodsDetail.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.13.</b>
                        
                        商品详情页面
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.14" data-path="C03-Goods/UserBrowseHistory.html">
            
                
                    <a href="./C03-Goods/UserBrowseHistory.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.14.</b>
                        
                        用户浏览历史记录
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="4" data-path="C04-Cart/index.html">
            
                
                    <a href="./C04-Cart/index.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.</b>
                        
                        购物车部分
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="4.1" data-path="C04-Cart/DataStructureDesign.html">
            
                
                    <a href="./C04-Cart/DataStructureDesign.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.1.</b>
                        
                        购物车数据存储设计
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.2" data-path="C04-Cart/Add.html">
            
                
                    <a href="./C04-Cart/Add.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.2.</b>
                        
                        购物车增加
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.3" data-path="C04-Cart/Query.html">
            
                
                    <a href="./C04-Cart/Query.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.3.</b>
                        
                        购物车查询
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.4" data-path="C04-Cart/Modify.html">
            
                
                    <a href="./C04-Cart/Modify.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.4.</b>
                        
                        购物车修改
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.5" data-path="C04-Cart/Delete.html">
            
                
                    <a href="./C04-Cart/Delete.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.5.</b>
                        
                        购物车删除
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.6" data-path="C04-Cart/SelectAll.html">
            
                
                    <a href="./C04-Cart/SelectAll.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.6.</b>
                        
                        购物车全选
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.7" data-path="C04-Cart/MergeCart.html">
            
                
                    <a href="./C04-Cart/MergeCart.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.7.</b>
                        
                        登录合并购物车
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="5" data-path="C05-Order/index.html">
            
                
                    <a href="./C05-Order/index.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.</b>
                        
                        订单部分
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="5.1" data-path="C05-Order/OrderDBModel.html">
            
                
                    <a href="./C05-Order/OrderDBModel.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.1.</b>
                        
                        订单数据库设计
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.2" data-path="C05-Order/PlaceOrder.html">
            
                
                    <a href="./C05-Order/PlaceOrder.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.2.</b>
                        
                        订单结算
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.3" data-path="C05-Order/SaveOrder.html">
            
                
                    <a href="./C05-Order/SaveOrder.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.3.</b>
                        
                        保存订单
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.4" data-path="C05-Order/OrderSuccess.html">
            
                
                    <a href="./C05-Order/OrderSuccess.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.4.</b>
                        
                        下单成功
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="6" data-path="C06-Pay/index.html">
            
                
                    <a href="./C06-Pay/index.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.</b>
                        
                        支付宝支付
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="6.1" data-path="C06-Pay/Alipay.html">
            
                
                    <a href="./C06-Pay/Alipay.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.1.</b>
                        
                        接入支付宝
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.2" data-path="C06-Pay/Paying.html">
            
                
                    <a href="./C06-Pay/Paying.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.2.</b>
                        
                        发起支付
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.3" data-path="C06-Pay/PaymentResult.html">
            
                
                    <a href="./C06-Pay/PaymentResult.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.3.</b>
                        
                        保存支付结果
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="7" data-path="C07-Xadmin.html">
            
                
                    <a href="./C07-Xadmin.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.</b>
                        
                        Xadmin
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="8" data-path="C08-Permission.html">
            
                
                    <a href="./C08-Permission.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>8.</b>
                        
                        用户权限控制
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="9" data-path="C09-Database/index.html">
            
                
                    <a href="./C09-Database/index.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>9.</b>
                        
                        数据库读写分离
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="9.1" data-path="C09-Database/MasterSlave.html">
            
                
                    <a href="./C09-Database/MasterSlave.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>9.1.</b>
                        
                        主从同步配置
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="9.2" data-path="C09-Database/ReadWriteSeparate.html">
            
                
                    <a href="./C09-Database/ReadWriteSeparate.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>9.2.</b>
                        
                        Django数据库读写分离
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter active" data-level="10" data-path="C10-Deploy.html">
            
                
                    <a href="./C10-Deploy.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>10.</b>
                        
                        Django部署
                    </a>
            
            
        </li>
    


            
            <li class="divider"></li>
            <li>
                <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
                    Published with GitBook
                </a>
            </li>
            
        </ul>
    </nav>
</div>

    <div class="book-body">
        <div class="body-inner">
            <div class="book-header" role="navigation">
    <!-- Actions Left -->
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="./" >美多商城</a>
    </h1>
</div>

            <div class="page-wrapper" tabindex="-1" role="main">
                <div class="page-inner">
                
                
                    <section class="normal" id="section-">
                    
                        <h1 id="&#x90E8;&#x7F72;">&#x90E8;&#x7F72;</h1>
<p><img src="images/&#x670D;&#x52A1;&#x5668;&#x67B6;&#x6784;&#x56FE;.png" alt="&#x670D;&#x52A1;&#x5668;&#x67B6;&#x6784;"></p>
<h3 id="1-&#x9759;&#x6001;&#x6587;&#x4EF6;">1. &#x9759;&#x6001;&#x6587;&#x4EF6;</h3>
<p>&#x5F53;Django&#x8FD0;&#x884C;&#x5728;&#x751F;&#x4EA7;&#x6A21;&#x5F0F;&#x65F6;&#xFF0C;&#x5C06;&#x4E0D;&#x518D;&#x63D0;&#x4F9B;&#x9759;&#x6001;&#x6587;&#x4EF6;&#x7684;&#x652F;&#x6301;&#xFF0C;&#x9700;&#x8981;&#x5C06;&#x9759;&#x6001;&#x6587;&#x4EF6;&#x4EA4;&#x7ED9;&#x9759;&#x6001;&#x6587;&#x4EF6;&#x670D;&#x52A1;&#x5668;&#x3002;</p>
<p>&#x6211;&#x4EEC;&#x5148;&#x6536;&#x96C6;&#x6240;&#x6709;&#x9759;&#x6001;&#x6587;&#x4EF6;&#x3002;&#x9879;&#x76EE;&#x4E2D;&#x7684;&#x9759;&#x6001;&#x6587;&#x4EF6;&#x9664;&#x4E86;&#x6211;&#x4EEC;&#x4F7F;&#x7528;&#x7684;front_end_pc&#x4E2D;&#x4E4B;&#x5916;&#xFF0C;django&#x672C;&#x8EAB;&#x8FD8;&#x6709;&#x81EA;&#x5DF1;&#x7684;&#x9759;&#x6001;&#x6587;&#x4EF6;&#xFF0C;&#x5982;&#x679C;rest_framework&#x3001;xadmin&#x3001;admin&#x3001;ckeditor&#x7B49;&#x3002;&#x6211;&#x4EEC;&#x9700;&#x8981;&#x6536;&#x96C6;&#x8FD9;&#x4E9B;&#x9759;&#x6001;&#x6587;&#x4EF6;&#xFF0C;&#x96C6;&#x4E2D;&#x4E00;&#x8D77;&#x653E;&#x5230;&#x9759;&#x6001;&#x6587;&#x4EF6;&#x670D;&#x52A1;&#x5668;&#x4E2D;&#x3002;</p>
<p><strong>&#x6211;&#x4EEC;&#x8981;&#x5C06;&#x6536;&#x96C6;&#x7684;&#x9759;&#x6001;&#x6587;&#x4EF6;&#x653E;&#x5230;front_end_pc&#x76EE;&#x5F55;&#x4E0B;&#x7684;static&#x76EE;&#x5F55;&#x4E2D;&#xFF0C;&#x6240;&#x4EE5;&#x5148;&#x521B;&#x5EFA;&#x76EE;&#x5F55;static&#x3002;</strong></p>
<p>Django&#x63D0;&#x4F9B;&#x4E86;&#x6536;&#x96C6;&#x9759;&#x6001;&#x6587;&#x4EF6;&#x7684;&#x65B9;&#x6CD5;&#x3002;&#x5148;&#x5728;&#x914D;&#x7F6E;&#x6587;&#x4EF6;&#x4E2D;&#x914D;&#x7F6E;&#x6536;&#x96C6;&#x4E4B;&#x540E;&#x5B58;&#x653E;&#x7684;&#x76EE;&#x5F55;</p>
<pre><code class="lang-python">STATIC_ROOT=os.path.join(os.path.dirname(BASE_DIR),<span class="hljs-string">&apos;front_end_pc/static&apos;</span>)
</code></pre>
<p>&#x7136;&#x540E;&#x6267;&#x884C;&#x6536;&#x96C6;&#x547D;&#x4EE4;</p>
<pre><code class="lang-shell">python manage.py collectstatic
</code></pre>
<p>&#x6211;&#x4EEC;&#x4F7F;&#x7528;Nginx&#x670D;&#x52A1;&#x5668;&#x4F5C;&#x4E3A;&#x9759;&#x6001;&#x6587;&#x4EF6;&#x670D;&#x52A1;&#x5668;</p>
<p>&#x6253;&#x5F00;Nginx&#x7684;&#x914D;&#x7F6E;&#x6587;&#x4EF6; </p>
<pre><code class="lang-shell">sudo vim /etc/nginx/sites-available/default
</code></pre>
<p>&#x5982;&#x679C;&#x662F;&#x7B2C;&#x4E00;&#x6B21;&#x914D;&#x7F6E;&#xFF0C;&#x53EF;&#x4EE5;&#x5C06;&#x6240;&#x6709;&#x914D;&#x7F6E;&#x5220;&#x9664;&#xFF0C;&#x518D;&#x6DFB;&#x52A0;&#x5982;&#x4E0B;&#x914D;&#x7F6E;</p>
<pre><code class="lang-python">server {
         listen       <span class="hljs-number">80</span>;
         server_name  www.meiduo.site;

        location / {
             root   front_end_pc&#x9879;&#x76EE;&#x8DEF;&#x5F84;;
             index  index.html index.htm;
         }

        <span class="hljs-comment"># &#x4F59;&#x4E0B;&#x7701;&#x7565;</span>
}
</code></pre>
<p>&#x91CD;&#x542F;Nginx&#x670D;&#x52A1;&#x5668;</p>
<pre><code class="lang-shell">sudo /usr/sbin/nginx -s reload
</code></pre>
<blockquote>
<p>&#x9996;&#x6B21;&#x542F;&#x52A8;nginx&#x670D;&#x52A1;&#x5668;</p>
<pre><code class="lang-shell">sudo /usr/sbin/nginx
</code></pre>
<p>&#x505C;&#x6B62;nginx&#x670D;&#x52A1;&#x5668;</p>
<pre><code class="lang-shell">sudo /usr/sbin/nginx -s stop
</code></pre>
</blockquote>
<h3 id="2--&#x52A8;&#x6001;&#x63A5;&#x53E3;">2.  &#x52A8;&#x6001;&#x63A5;&#x53E3;</h3>
<p>&#x5728;&#x9879;&#x76EE;&#x4E2D;&#x590D;&#x5236;settings.py&#xFF0C;&#x5C06;&#x65B0;&#x6587;&#x4EF6;&#x6539;&#x540D;&#x4E3A;settings_product.py</p>
<p>&#x4FEE;&#x6539;&#x914D;&#x7F6E;&#x6587;&#x4EF6;settings_product.py</p>
<pre><code class="lang-python">DEBUG = <span class="hljs-keyword">True</span>

ALLOWED_HOSTS = [
    ...,
    <span class="hljs-string">&apos;www.meiduo.site&apos;</span><span class="hljs-comment"># &#x6DFB;&#x52A0;</span>
]

CORS_ORIGIN_WHITELIST = (
    ...
    <span class="hljs-string">&apos;www.meiduo.site&apos;</span><span class="hljs-comment"># &#x6DFB;&#x52A0;</span>
)
</code></pre>
<p>&#x4FEE;&#x6539;wsgi.py&#x6587;&#x4EF6;</p>
<pre><code class="lang-python">os.environ.setdefault(<span class="hljs-string">&quot;DJANGO_SETTINGS_MODULE&quot;</span>, <span class="hljs-string">&quot;meiduo_api.settings_product&quot;</span>)
</code></pre>
<p>django&#x7684;&#x7A0B;&#x5E8F;&#x901A;&#x5E38;&#x4F7F;&#x7528;uwsgi&#x670D;&#x52A1;&#x5668;&#x6765;&#x8FD0;&#x884C;</p>
<p>&#x5B89;&#x88C5;uwsgi</p>
<pre><code class="lang-python">pip install uwsgi
</code></pre>
<p>&#x5728;&#x9879;&#x76EE;meiduo_api&#x76EE;&#x5F55;&#x4E0B;&#x521B;&#x5EFA;uwsgi&#x914D;&#x7F6E;&#x6587;&#x4EF6; uwsgi.ini</p>
<pre><code class="lang-ini"><span class="hljs-title">[uwsgi]</span>
<span class="hljs-comment">#&#x4F7F;&#x7528;nginx&#x8FDE;&#x63A5;&#x65F6;&#x4F7F;&#x7528;&#xFF0C;Django&#x7A0B;&#x5E8F;&#x6240;&#x5728;&#x670D;&#x52A1;&#x5668;&#x5730;&#x5740;</span>
<span class="hljs-setting">socket=<span class="hljs-value"><span class="hljs-number">127.0</span>.<span class="hljs-number">0.1</span>:<span class="hljs-number">8001</span></span></span>
<span class="hljs-comment">#&#x76F4;&#x63A5;&#x505A;web&#x670D;&#x52A1;&#x5668;&#x4F7F;&#x7528;&#xFF0C;Django&#x7A0B;&#x5E8F;&#x6240;&#x5728;&#x670D;&#x52A1;&#x5668;&#x5730;&#x5740;</span>
<span class="hljs-comment">#http=127.0.0.1:8001</span>
<span class="hljs-comment">#&#x9879;&#x76EE;&#x76EE;&#x5F55;</span>
<span class="hljs-setting">chdir=<span class="hljs-value">/home/python/Desktop/meiduo/meiduo_api</span></span>
<span class="hljs-comment">#&#x9879;&#x76EE;&#x4E2D;wsgi.py&#x6587;&#x4EF6;&#x7684;&#x76EE;&#x5F55;&#xFF0C;&#x76F8;&#x5BF9;&#x4E8E;&#x9879;&#x76EE;&#x76EE;&#x5F55;</span>
<span class="hljs-setting">wsgi-file=<span class="hljs-value">meiduo_api/wsgi.py</span></span>
<span class="hljs-comment"># &#x8FDB;&#x7A0B;&#x6570;</span>
<span class="hljs-setting">processes=<span class="hljs-value"><span class="hljs-number">4</span></span></span>
<span class="hljs-comment"># &#x7EBF;&#x7A0B;&#x6570;</span>
<span class="hljs-setting">threads=<span class="hljs-value"><span class="hljs-number">2</span></span></span>
<span class="hljs-comment"># uwsgi&#x670D;&#x52A1;&#x5668;&#x7684;&#x89D2;&#x8272;</span>
<span class="hljs-setting">master=<span class="hljs-value"><span class="hljs-keyword">True</span></span></span>
<span class="hljs-comment"># &#x5B58;&#x653E;&#x8FDB;&#x7A0B;&#x7F16;&#x53F7;&#x7684;&#x6587;&#x4EF6;</span>
<span class="hljs-setting">pidfile=<span class="hljs-value">uwsgi.pid</span></span>
<span class="hljs-comment"># &#x65E5;&#x5FD7;&#x6587;&#x4EF6;&#xFF0C;&#x56E0;&#x4E3A;uwsgi&#x53EF;&#x4EE5;&#x8131;&#x79BB;&#x7EC8;&#x7AEF;&#x5728;&#x540E;&#x53F0;&#x8FD0;&#x884C;&#xFF0C;&#x65E5;&#x5FD7;&#x770B;&#x4E0D;&#x89C1;&#x3002;&#x6211;&#x4EEC;&#x4EE5;&#x524D;&#x7684;runserver&#x662F;&#x4F9D;&#x8D56;&#x7EC8;&#x7AEF;&#x7684;</span>
<span class="hljs-setting">daemonize=<span class="hljs-value">uwsgi.log</span></span>
<span class="hljs-comment"># &#x6307;&#x5B9A;&#x4F9D;&#x8D56;&#x7684;&#x865A;&#x62DF;&#x73AF;&#x5883;</span>
<span class="hljs-setting">virtualenv=<span class="hljs-value">/home/python/.virtualenvs/py3_django</span></span>
</code></pre>
<p>&#x542F;&#x52A8;uwsgi&#x670D;&#x52A1;&#x5668;</p>
<pre><code class="lang-shell">uwsgi --ini uwsgi.ini
</code></pre>
<blockquote>
<p>&#x6CE8;&#x610F;&#x5982;&#x679C;&#x60F3;&#x8981;&#x505C;&#x6B62;&#x670D;&#x52A1;&#x5668;&#xFF0C;&#x9664;&#x4E86;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;kill&#x547D;&#x4EE4;&#x4E4B;&#x5916;&#xFF0C;&#x8FD8;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;</p>
<pre><code class="lang-shell">uwsgi --stop uwsgi.pid
</code></pre>
</blockquote>
<p>&#x4FEE;&#x6539;Nginx&#x914D;&#x7F6E;&#x6587;&#x4EF6;&#xFF0C;&#x6DFB;&#x52A0;&#x5982;&#x4E0B;&#x4EE3;&#x7801;&#xFF0C;&#x8BA9;Nginx&#x63A5;&#x6536;&#x5230;&#x8BF7;&#x6C42;&#x540E;&#x8F6C;&#x53D1;&#x7ED9;uwsgi&#x670D;&#x52A1;&#x5668;</p>
<pre><code class="lang-python">     upstream meiduo {
         server <span class="hljs-number">127.0</span><span class="hljs-number">.0</span><span class="hljs-number">.1</span>:<span class="hljs-number">8001</span>;  <span class="hljs-comment"># &#x6B64;&#x5904;&#x4E3A;uwsgi&#x8FD0;&#x884C;&#x7684;ip&#x5730;&#x5740;&#x548C;&#x7AEF;&#x53E3;&#x53F7;</span>
         <span class="hljs-comment"># &#x5982;&#x679C;&#x6709;&#x591A;&#x53F0;&#x670D;&#x52A1;&#x5668;&#xFF0C;&#x53EF;&#x4EE5;&#x5728;&#x6B64;&#x5904;&#x7EE7;&#x7EED;&#x6DFB;&#x52A0;&#x670D;&#x52A1;&#x5668;&#x5730;&#x5740;</span>
     }
     server {
         listen  <span class="hljs-number">8000</span>;
         server_name api.meiduo.site;
         location / {
             include uwsgi_params;
             uwsgi_pass meiduo;
         }
     }
</code></pre>
<p>&#x91CD;&#x542F;nginx</p>
<pre><code class="lang-shell">sudo /usr/sbin/nginx -s reload
</code></pre>
<p>&#x4F7F;&#x7528;&#x5982;&#x4E0B;&#x57DF;&#x540D;&#x53EF;&#x4EE5;&#x8BBF;&#x95EE;&#x7F51;&#x7AD9;</p>
<pre><code class="lang-shell">www.meiduo.site
</code></pre>

                    
                    </section>
                
                
                </div>
            </div>
        </div>

        
        <a href="./C09-Database/ReadWriteSeparate.html" class="navigation navigation-prev navigation-unique" aria-label="Previous page: Django数据库读写分离"><i class="fa fa-angle-left"></i></a>
        
        
    </div>
</div>

        
<script src="gitbook/app.js"></script>

    
    <script src="gitbook/plugins/gitbook-plugin-toggle-chapters/toggle.js"></script>
    

    
    <script src="gitbook/plugins/gitbook-plugin-search/lunr.min.js"></script>
    

    
    <script src="gitbook/plugins/gitbook-plugin-search/search.js"></script>
    

    
    <script src="gitbook/plugins/gitbook-plugin-sharing/buttons.js"></script>
    

    
    <script src="gitbook/plugins/gitbook-plugin-fontsettings/buttons.js"></script>
    

<script>
require(["gitbook"], function(gitbook) {
    var config = {"toggle-chapters":{},"highlight":{},"search":{"maxIndexSize":1000000},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2}};
    gitbook.start(config);
});
</script>

        <!-- body:end -->
    </body>
    <!-- End of book 美多商城 -->
</html>
